package cn.simon.controller;


import cn.simon.pojo.User;
import cn.simon.rabbitmq.MQsend;
import cn.simon.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
*
*simon-yian 开心
 * @author simon-yian
 *
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private MQsend mQsend;

    @ResponseBody
    @RequestMapping("/info")
    public RespBean info(User user ,HttpSession session){
        return RespBean.success(user);
    }

    /**
     * @功能描述:测试发送rabbitmq消息
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 16:08
     */
    @RequestMapping("/meg")
    @ResponseBody
    public void meg(){
        mQsend.send("hello");
    }

    /**
     * @功能描述: 广播模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:14
     */
    @RequestMapping("/fanoutmeg")
    @ResponseBody
    public void fanoutmeg(){
        mQsend.sendFanExchange("hello");
    }

    /**
     * @功能描述:直连模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:17
     */
    @RequestMapping("/directRedMeg")
    @ResponseBody
    public void directRedMeg(){
        mQsend.sendDirectExchangeRed("hello,Red");
    }

    /**
     * @功能描述:直连模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:17
     */
    @RequestMapping("/directGreedMeg")
    @ResponseBody
    public void directGreedMeg(){
        mQsend.sendDirectExchangeGreed("hello,Greed");
    }
    /**
     * @功能描述: 主题模式
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/6 22:49
     */
    @RequestMapping(value = "/topicMeg01")
    @ResponseBody
    public void topicMeg01(){
        mQsend.sendTopicExchange01("hello");
    }
    @RequestMapping(value = "/topicMeg02")
    @ResponseBody
    public void topicMeg02(){
        mQsend.sendTopicExchange02("hello");
    }

    @RequestMapping(value = "/topicMeg03")
    @ResponseBody
    public void topicMeg03(){
        mQsend.sendTopicExchange03("hello");
    }

    /**
     * @功能描述: 头部信息
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/7 0:50
     */
    @RequestMapping(value = "/headerMeg01")
    @ResponseBody
    public void headerMeg01(){
        mQsend.sendHeadersExchange01("hello");
    }
    /**
     * @功能描述: 头部信息
     * @Param:
     * @Return:
     * @Author simon-yi'an
     * @Date 2022/11/7 0:50
     */
    @RequestMapping(value = "/headerMeg02")
    @ResponseBody
    public void headerMeg02(){
        mQsend.sendHeadersExchange02("hello");
    }
}
